﻿#define _CRT_SECURE_NO_WARNINGS//递归和非递归分别实现strlen
#include<stdio.h>

my_strlen1(char* str)
{
	if (*str != '\0')
		return  1 + my_strlen1(str + 1);
	else
		return 0;
}
my_strlen2(char* str)
{
	int count = 0;
	while (*str != '\0')
	{
		count++;
		str = str + 1;
	}
	return count;
}
int main()
{
	char arr[] = "abcdef";
	int n = my_strlen1(arr);
	printf("数组：%s\n", arr);
	printf("递归法：%d\n", n);
	int m = my_strlen2(arr);
	printf("非递归法：%d\n", m);
	return 0;
}